package com.bishe.demo.modules.hotel.common.controller;

import com.bishe.demo.modules.common.entity.ResultEntity;
import com.bishe.demo.modules.hotel.common.entity.HotelImage;
import com.bishe.demo.modules.hotel.common.service.HotelImageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/hotel")
public class HotelImageController {
    @Autowired
    private HotelImageService imageService;

    @PostMapping(value = "/image", consumes = "application/json")
    ResultEntity<HotelImage> insertImage(@RequestBody HotelImage image) {
        return imageService.insertImage(image);
    }

    @PutMapping(value = "/image", consumes = "application/json")
    ResultEntity<HotelImage> updateImage(@RequestBody HotelImage image) {
        return imageService.updateImage(image);
    }

    @DeleteMapping(value = "/image/{imageId}")
    ResultEntity<HotelImage> deleteImageByImageId(@PathVariable int imageId) {
        return imageService.deleteImageByImageId(imageId);
    }

    @GetMapping(value = "/images")
    List<HotelImage> getAllImages() {
        return imageService.getAllImages();
    }
}
